package net.kunyv.util;

import net.kunyv.entity.Item;

import java.io.*;
import java.util.ArrayList;
import java.util.List;




public class TxtUtil
{
    public static List<Item> getSelectlists() {
        List<Item> result = new ArrayList<>();
        String dir = System.getProperty("user.dir");
        File file = new File(dir + "/selectlist.txt");
        String encoding = "UTF-8";
        try {
            InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding);
            BufferedReader bufferedReader = new BufferedReader(read);
            String lineTxt = null;
            while ((lineTxt = bufferedReader.readLine()) != null) {
                String[] kv = lineTxt.split("@");
                Item item = new Item(kv[0], kv[1]);
                result.add(item);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }
}
